package com.sky.config;


import com.sky.properties.MinioProperties;
import com.sky.utils.MinioUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class MinioConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public MinioUtil minioUtil(MinioProperties minioProperties){

        log.info("创建Minio单例Bean...");
        log.info("====================== Minio OSS 配置信息 ======================");
        log.info("Minio OSS 访问域名: http://{}.{}", minioProperties.getBucketName(), minioProperties.getEndpoint());
        log.info("Minio OSS 桶名称: {}", minioProperties.getBucketName());
        log.info("===============================================================");
        return new MinioUtil(minioProperties.getEndpoint(),
                minioProperties.getAccessKey(),
                minioProperties.getSecretKey(),
                minioProperties.getBucketName());
    }


}
